home *** CD-ROM | disk | FTP | other *** search
- head 1.8;
- branch ;
- access ;
- symbols ;
- locks ; strict;
- comment @ * @;
-
-
- 1.8
- date 91.01.28.12.30.55; author kupfer; state Exp;
- branches ;
- next 1.7;
-
- 1.7
- date 89.06.23.11.27.50; author rab; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 88.11.21.18.04.12; author douglis; state Exp;
- branches ;
- next 1.5;
-
- 1.5
- date 88.08.04.08.29.21; author ouster; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 88.08.01.17.14.04; author ouster; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 88.08.01.12.14.07; author ouster; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.08.01.12.09.47; author ouster; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.08.01.10.42.35; author ouster; state Exp;
- branches ;
- next ;
-
-
- desc
- @@
-
-
- 1.8
- log
- @Add OPT_TIME flavor. Use _ARGS_ instead of comments in the procedure
- declarations.
- @
- text
- @/*
- * option.h --
- * This defines the Option type and the interface to the
- * Opt_Parse library call that parses command lines.
- *
- * Copyright 1988, 1991 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- *
- * $Header: /sprite/src/lib/include/RCS/option.h,v 1.7 89/06/23 11:27:50 rab Exp Locker: kupfer $ SPRITE (Berkeley)
- */
-
- #ifndef _OPTION
- #define _OPTION
-
- #include <cfuncproto.h>
-
- /*
- * An array of option descriptions (type Option) is passed into the
- * routine which interprets the command line. Each option description
- * includes the key-string that indicates the option, a type for the option,
- * the address of an associated variable, and a documentation message
- * that is printed when the command is invoked with a single argument
- * of '?'
- */
-
- typedef struct Option {
- int type; /* Indicates option type; see below */
- char *key; /* The key string that flags option */
- char * address; /* Address of variable to modify */
- char *docMsg; /* Documentation message */
- } Option;
- /*
- * Values for type:
- *
- * OPT_CONSTANT(val) - if the flag is present then set the
- * associated (integer) variable to val.
- * Val must be a non-negative integer.
- * OPT_TRUE - if the flag is present then set the
- * associated (integer) variable to TRUE (1).
- * OPT_FALSE - if the flag is present then set the
- * associated (integer) variable to FALSE (0).
- * OPT_INT - if the flag is present then the next argument
- * on the command line is interpreted as an
- * integer and that value is assigned to the
- * options associated variable.
- * OPT_STRING - if the flag is present then the next argument
- * on the command line is copied into the string
- * variable associated with the option.
- * OPT_REST - if the flag is present, inhibit processing of
- * later options, so that they're all returned
- * to the caller in argv. In addition, set the
- * associated variable to the index of the first
- * of these arguments in the returned argv.
- * This permits a program to allow a flag to
- * separate its own options from options it will
- * pass to another program.
- * OPT_FLOAT - if the flag is present then the next argument
- * on the command line is interpreted as a
- * "double" and that value is assigned to the
- * option's associated variable.
- * OPT_TIME - if the flag is present then the next argument
- * on the command line is interpreted as a date
- * and time. The corresponding time value
- * (number of seconds past the epoch) is assigned
- * to the option's associated variable.
- * OPT_FUNC - if the flag is present, pass the next argument
- * to "address" as a function. The function
- * should be declared:
- * int
- * func(optString, arg)
- * char *optString;
- * char *arg;
- * Func should return non-zero if the argument
- * was consumed or zero if not. "optString" is
- * the option key string that caused the
- * function to be called and "arg" is the next
- * argument (if there is no next argument then
- * "arg" will be NULL).
- * OPT_GENFUNC - if the flag is present, pass the remaining
- * arguments and the number of arguments to
- * "address" as a function. The function should
- * be declared:
- * int
- * func(optString, argc, argv)
- * char *optString;
- * int argc;
- * char **argv;
- * and should return the new number of arguments
- * left in argv. argv should have been shuffled
- * to eliminate the arguments func consumed.
- * OPT_DOC - a dummy entry. Exists mostly for its
- * documentation string. As an additional side
- * effect, if its key string an argument,
- * Opt_Parse will treat it like a question mark
- * (i.e. print out the program's usage and exit).
- */
-
- #define OPT_CONSTANT(val) ((int) val)
- #define OPT_FALSE 0
- #define OPT_TRUE 1
- #define OPT_INT -1
- #define OPT_STRING -2
- #define OPT_REST -3
- #define OPT_FLOAT -4
- #define OPT_FUNC -5
- #define OPT_GENFUNC -6
- #define OPT_DOC -7
- #define OPT_TIME -8
-
- /*
- * Flag values for Opt_Parse:
- *
- * OPT_ALLOW_CLUSTERING - Permit many flags to be clustered under
- * a single "-". In otherwords, treat
- * "foo -abc" the same as "foo -a -b -c".
- * OPT_OPTIONS_FIRST - Stop parsing if something other than an
- * option (starting with a hyphen) is encountered.
- */
-
- #define OPT_ALLOW_CLUSTERING 1
- #define OPT_OPTIONS_FIRST 2
-
- /*
- * Exported procedures:
- */
-
- int Opt_Parse _ARGS_ ((int argc, char *argv[], Option *optionArray,
- int numOptions, int flags));
-
- void Opt_PrintUsage _ARGS_ ((char *commandName, Option *optionArray,
- int numOptions));
-
- /*
- * Macro to determine size of option array:
- */
-
- #define Opt_Number(optionArray) (sizeof(optionArray)/sizeof((optionArray)[0]))
-
- #endif /* _OPTION */
- @
-
-
- 1.7
- log
- @*** empty log message ***
- @
- text
- @d6 1
- a6 1
- * Copyright 1988 Regents of the University of California
- d15 1
- a15 1
- * $Header: /sprite/src/lib/include/RCS/option.h,v 1.6 88/11/21 18:04:12 douglis Exp Locker: rab $ SPRITE (Berkeley)
- d21 2
- d67 5
- d114 1
- d133 5
- a137 13
- int
- Opt_Parse( /* int argc;
- char *argv[];
- Option *optionArray;
- int numOptions;
- int flags;
- */ );
-
- void
- Opt_PrintUsage( /* char *commandName;
- Option *optionArray;
- int numOptions;
- */ );
- @
-
-
- 1.6
- log
- @added OPT_OPTIONS_FIRST option.
- @
- text
- @d15 1
- a15 1
- * $Header: /sprite/src/lib/include/RCS/option.h,v 1.5 88/08/04 08:29:21 ouster Exp Locker: douglis $ SPRITE (Berkeley)
- d145 1
- a145 1
- #endif _OPTION
- @
-
-
- 1.5
- log
- @Changed allowClustering from a Boolean to a general flags word.
- @
- text
- @d15 1
- a15 1
- * $Header: option.h,v 1.4 88/08/01 17:14:04 ouster Exp $ SPRITE (Berkeley)
- d114 2
- d119 1
- @
-
-
- 1.4
- log
- @Eliminate obsolete typedef.
- @
- text
- @d15 1
- a15 1
- * $Header: option.h,v 1.3 88/08/01 12:14:07 ouster Exp $ SPRITE (Berkeley)
- d109 10
- d127 1
- a127 1
- int allowClustering;
- @
-
-
- 1.3
- log
- @Redeclare Opt_Parse.
- @
- text
- @d15 1
- a15 1
- * $Header: option.h,v 1.1 88/08/01 10:42:35 ouster Exp $ SPRITE (Berkeley)
- a28 13
-
- typedef enum {
- OPT_TRUE, /* Set *address TRUE */
- OPT_FALSE, /* Set *address FALSE */
- OPT_INT, /* Set *address to next arg as an integer */
- OPT_STRING, /* Set *address to next arg */
- OPT_REST, /* Ignore the rest of the arguments */
- OPT_FLOAT, /* Set *address to next arg as a float */
- OPT_FUNC, /* Use address as a function to process next arg */
- OPT_GENFUNC, /* Use address as a function to process as many
- * arguments as it wants */
- OPT_DOC /* Not a real option, just documentation */
- } OptionType;
- @
-
-
- 1.2
- log
- @Change parameter order.
- @
- text
- @d125 1
- a125 1
- void
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d15 1
- a15 1
- * $Header: proto.h,v 1.2 88/03/11 08:39:40 ouster Exp $ SPRITE (Berkeley)
- d128 1
- a129 1
- Option *optionArray;
- d135 1
- a136 1
- Option *optionArray;
- @
-